package com.base.cn.platform.os.controller.user.sms;

import com.base.cn.platform.os.controller.cmmon.ApiBaseController;
import com.base.cn.platform.os.service.manage.user.sms.UserSendSmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 用户接口Controller
 * @author s.li
 * @create 2018-08-27-9:32
 */
@RestController
@RequestMapping("/api/user")
public class ApiUserSendSmsController extends ApiBaseController {

    @Autowired
    private UserSendSmsService userSendSmsService;

    /**
     * <p>通用发送短信接口</p>
     * @param mobile 手机号
     * @param status 类型，1注册，2找回密码，3发送绑定验证码，4发送更换绑定验证码，5完善资料
     *  @param sessionId 完善资料时传输入
     * @return Map<String,Object>
     */
    @RequestMapping("/sendMobileCode")
    public Map<String,Object> sendMobileCode(@RequestParam("mobile") String mobile,
                                             @RequestParam("status") int status,
                                             @RequestParam(value = "sessionId",required = false) String sessionId){
        return userSendSmsService.sendMobileCode(mobile,status,sessionId);
    }

    /**
     * 发送邮箱验证码接口
     * @param email 接验证码的邮箱号
     * @param status 类型，1=注册，2=找回密码，3=绑定邮箱号（用于验证新绑定的邮箱号），4=改绑邮箱号（用于验证原绑定的邮箱号）
     * @return Map<String,Object>
     */
    @RequestMapping("/sendEmailCode")
    public Map<String,Object> sendEmailCode(@RequestParam("email") String email,
                                            @RequestParam("status") int status){
        return userSendSmsService.sendEmailCode(email,status);
    }
}
